In computer science, memory management is the act of managing computer memory. In its simpler forms, this involves providing ways to allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. Garbage collection (GC) is a form of automatic memory management. The garbage collector or collector attempts to reclaim garbage, or memory used by objects that will never be accessed or mutated again by the application. Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory, thereby preventing many potential bugs and headaches. The name “garbage collection” implies that objects that are no longer needed by the program are “garbage” and can be thrown away. A more accurate and up-to-date metaphor might be “memory recycling.” When an object is no longer referenced by the program, the heap space it occupies must be recycled so that the space is available for subsequent new objects. The garbage collector must somehow determine which objects are no longer referenced by the program and make available the heap space occupied by such unreferenced objects.
Any garbage collection algorithm must do two basic things. First, it must detect garbage objects. Second, it must reclaim the heap space used by the garbage objects and make it available to the program. Garbage detection is ordinarily accomplished by defining a set of roots and determining reachability from the roots. An object is reachable if there is some path of references from the roots by which the executing program can access the object. The roots are always accessible to the program. Any objects that are reachable from the roots are considered live. Objects that are not reachable are considered garbage, because they can no longer affect the future course of program execution.
The current garbage collection algorithms have many disadvantages. The garbage collection is closely related to the programming language, which inhibits a reuse of a common runtime. The garbage collection extends a programming language to a runtime environment and replaces a huge part of features, which are already implemented by the operating system. In addition, the existing garbage collection is decoupled from the memory management of the operating system that makes the use of existing monitoring, profiling, debugging and administration tools impossible. Furthermore, current garbage collection is unpredictable at start and runtime. Thus the current garbage collection algorithms are performance bottlenecks and make CPU (Central Processing Unit) response times unpredictable.